package com.ejiaoyi.api.dto;

import com.ejiaoyi.api.enums.ApiCode;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * Api 返回类
 *
 * @author unknownChivalrous
 * @since 2020-5-9
 */
@Data
public class Rest implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "编号", position = 1, example = "1")
    private String code;

    @ApiModelProperty(value = "信息", position = 2, example = "成功")
    private String msg;

    public void setCode(ApiCode code) {
        if (code != null) {
            this.code = code.getCode();
            String msg = code.getMsg();
            if (StringUtils.isNotEmpty(msg)) {
                this.msg = msg;
            }
        }
    }
}
